package org.factoryMethod.singletone;

import java.lang.reflect.Constructor;

public class SingletoneFactory {
	private static Singletone singletone;
	static {
		try {
			// 获取一个类的标识
			Class singletoneClass = Class.forName(Singletone.class.getName());
			// 获取该类的无参构造函数
			Constructor constructor = singletoneClass.getDeclaredConstructor();
			// 更改其访问权限，使其可以被访问
			constructor.setAccessible(true);
			// 实例化
			singletone = (Singletone) constructor.newInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static Singletone getSingletone() {
		return singletone;
	}
}
